{extend name="common/common" /}

{block name="style"}
<style type="text/css">
.layui-form-label{
	width: 90px;
}
.btn.btn-info{
	margin-top: 2px;
}
.configList{
	display: block;
	border: 2px solid #e7eaec;
	padding: 15px;
	height: 300px;
	overflow-y: scroll;
}
.badge{
	background-color: #ec4758;
	color: #FFF;
	padding:3px 4px;
	font-weight: 1;
	border-radius: 50%;
	cursor: pointer;
}
.showRemark{
	cursor: pointer;
}
.StaticTableBox{
	overflow-x: auto;
}
.table.table-bordered.table-hover.text-center{
	min-width: 800px;
}
#ID_Photo{
	width: 190px;
	height: 271px;
	background: blue;
	color:#FFF;
	line-height: 421px;
	cursor: pointer;
}
</style>
{/block}

{block name="content"}
<div class="wrapper wrapper-content animated fadeInRight col-lg-12">
	<!-- start of 学员信息详情 -->
    <div class="ibox float-e-margins col-lg-8">
        <div class="ibox-title">
            <h5>学员信息详情</h5>
        </div>
        <div class="ibox-content">
			<div class="layui-form-item text-center">
				<label class="layui-form-label">一寸照片</label>
				<div class="layui-input-inline">
					{if authCheck('attachment/uploadidphoto')}
					<div id="ID_Photo" data-action="uploadIdPhoto" data-multiple="false" data-ext="png,jpg,jpeg" data-upload="stidphoto/stIdPhoto_{$stInfo.id}">
					{else}
					<div id="ID_Photo">
					{/if}
					</div>
				</div>
			</div>
			<form class="layui-form" action="" id="editForm">
				<div class="layui-form-item">
					<label class="layui-form-label">学员姓名</label>
					<div class="layui-input-inline">
						<input type="text" name="name" value="{$stInfo.name|default=''}" class="layui-input">
					</div>
					<label class="layui-form-label">联系电话</label>
					<div class="layui-input-inline">
						<input value="{$stInfo.phone|default=''}" type="text" name="phone" class="layui-input">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">学　　校</label>
					<div class="layui-input-inline">
						<input value="{$stInfo.school|default=''}" type="text" name="school" readonly class="layui-input selectSchool school layui-disabled" disabled>
						<input value="{$stInfo.school_id|default=''}" type="hidden" name="school_id" class="school_id" disabled>
					</div>

					<label class="layui-form-label">选择专业</label>
					<div class="layui-input-inline">
						<input value="{$stInfo.major|default=''}" type="text" name="major" readonly class="layui-input selectSchool major layui-disabled" disabled>
						<input value="{$stInfo.major_id|default=''}" type="hidden" name="major_id" class="major_id" disabled>
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">批　　次</label>
					<div class="layui-input-inline">
						<input type="text" name="batch" value="{$stInfo.batch|default=''}" class="layui-input layui-disabled" readonly>
					</div>

					<label class="layui-form-label">班　　级</label>
					<div class="layui-input-inline">
						<input type="text" name="class" value="{$stInfo.class|default=''}" class="layui-input layui-disabled" readonly>
					</div>

				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">民　　族</label>
					<div class="layui-input-inline">
						<input value="{$stInfo.nation|default=''}" type="text" name="nation" class="layui-input">
					</div>

					<label class="layui-form-label">身份证号</label>
					<div class="layui-input-inline">
						<input value="{$stInfo.id_card|default=''}" type="text" name="id_card" class="layui-input">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">生　　日</label>
					<div class="layui-input-inline">
						<input value="{$stInfo.birthday|default=''}" type="text" name="birthday" readonly class="layui-input birthday">
					</div>
					<label class="layui-form-label">性　　别</label>
					<div class="layui-input-inline">
						<select name="sex" class="layui-input">
							{if $stInfo.sex eq 0}<option value="0" selected>保密</option>
							{else}<option value="0">保密</option>
							{/if}
							{if $stInfo.sex eq 1}<option value="1" selected>男</option>
							{else}<option value="1">男</option>
							{/if}
							{if $stInfo.sex eq 2}<option value="2" selected>女</option>
							{else}<option value="2">女</option>
							{/if}
						</select>
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">考试时间</label>
					<div class="layui-input-inline">
						<input value="{$stInfo.test_time|default=''}" type="text" name="test_time" readonly class="layui-input test_time">
					</div>
					<label class="layui-form-label">学籍状态</label>
					<div class="layui-input-inline">
						<select name="school_roll" class="layui-input" disabled>
							{if $stInfo.school_roll eq 0}<option value="0" selected>报名</option>
							{else}<option value="0">报名</option>
							{/if}
							{if $stInfo.school_roll eq 1}<option value="1" selected>在读</option>
							{else}<option value="1">在读</option>
							{/if}
							{if $stInfo.school_roll eq 2}<option value="2" selected>毕业</option>
							{else}<option value="2">毕业</option>
							{/if}
							{if $stInfo.school_roll eq 3}<option value="3" selected>休学</option>
							{else}<option value="3">休学</option>
							{/if}
							{if $stInfo.school_roll eq 4}<option value="4" selected>退学</option>
							{else}<option value="4">退学</option>
							{/if}
						</select>
					</div>
				</div>

				<div class="layui-form-item text-center">
		        	<input type="hidden" value="{$stInfo.id|default=''}" name="id">
		        	{if authCheck('education/editstinfo')}
		            <button class="btn btn-primary" type="submit">保存</button>
		            {/if}
				</div>

			</form>
		</div>
	</div>
	<!-- end of 学员信息详情 -->

	<div class="ibox float-e-margins">
		<div class="ibox-title">
            <h5>学籍变动信息</h5>
        </div>
		<div class="ibox-content">
			<div class="StaticTableBox">
			<table class="table table-bordered table-hover text-center">
				<thead>
					<tr>
						<th class="text-center">ID</th>
						<th class="text-center">变动原因</th>
						<th class="text-center">是否异常</th>
						<th class="text-center">由(学校-专业-批次-班级)</th>
						<th class="text-center">转至(学校-专业-批次-班级)</th>
						<th class="text-center">变动时间</th>
						<th class="text-center">备注</th>
					</tr>
				</thead>
				<tbody>
					{volist name="$rollInfo" id="v"}
					<tr>
						<td>{$v.id}</td>
						<td>
							{$v.roll_name|default=""}
						</td>
						<td>
							{if $v.abnormal eq 0}正常
							{else}<span class="span-danger span-strong">异常</span>
							{/if}
						</td>
						<td>{$v.school}-{$v.major}-{$v.batch}-{$v.class}</td>
						<td>{$v.to_school}-{$v.to_major}-{$v.to_batch}-{$v.to_class}</td>
						<td>{$v.create_time|date="Y-m-d",###}</td>
						<td>
							{if condition="mb_strlen($v.remark) > 20"}
								<span class="span-info showRemark" data-param="{$v.remark}">{:mb_substr($v.remark,0,20).'...'}</span>
							{else}
								{$v.remark}
							{/if}
						</td>
					</tr>
					{/volist}
				</tbody>
			</table>
			</div>
		</div>
	</div>
	<!-- end of 学籍变动信息 -->
	<div class="ibox float-e-margins">
		<div class="ibox-title">
            <h5>学员财务信息</h5>
        </div>
		<div class="ibox-content">
			<div class="StaticTableBox">
			<table class="table table-bordered table-hover text-center">
				<thead>
					<tr>
						<th class="text-center">ID</th>
						<th class="text-center">订单单号</th>
						<th class="text-center">流水单号</th>
						<th class="text-center">来源</th>
						<th class="text-center">金额</th>
						<th class="text-center">到期时间</th>
						<th class="text-center">状态</th>
						<th class="text-center">备注</th>
					</tr>
				</thead>
				<tbody>
					{volist name="$FinanceInfo" id="v"}
					<tr>
						<td>{$v.id}</td>
						<td>{$v.order_sn}</td>
						<td>{$v.account_sn}</td>
						<td>
							{if $v.source eq 0}学费
							{elseif $v.source eq 1}报销
							{elseif $v.source eq 2}罚款
							{elseif $v.source eq 3}退款
							{else}其他
							{/if}
						</td>
						<td>{$v.total_amount}</td>
						<td>
							{$v.finish_time|date="Y-",###}
							{if condition=" date('Ym',$v.finish_time) == date('Ym',time()) "}
								<span class="span-danger span-strong">{$v.finish_time|date="m",###}</span>
							{else}
								{$v.finish_time|date="m",###}
							{/if}
							{$v.finish_time|date="-d",###}
						</td>
						<td>
							{if $v.status eq 0}未支付
							{elseif $v.status eq 1}<span class="span-primary">已支付</span>
							{elseif $v.status eq 2}<span class="span-warning">已逾期</span>
							{elseif $v.status eq 3}已拒绝
							{elseif $v.status eq 4}已同意
							{elseif $v.status eq 5}<span class="span-gray"></span>已取消
							{else}其他
							{/if}
						</td>
						<td>
							{if condition="mb_strlen($v.remarks) > 20"}
								<span class="span-info showRemark" data-param="{$v.remarks}">{:mb_substr($v.remarks,0,20).'...'}</span>
							{else}
								{$v.remarks}
							{/if}
						</td>
					</tr>
					{/volist}
				</tbody>
			</table>
			</div>
		</div>
	</div>
	<!-- end of 学员财务信息 -->
</div>

<div class="laycontent" style="display: none;width: 300px;padding: 30px 15px;">
    <ul id="tree"></ul>
</div>

<div class="layclassify" style="display: none;width: 300px;padding: 30px 15px;">
    <ul id="classifytree"></ul>
</div>

<div class="layRemark" style="display: none;text-indent: 2rem;padding: 15px;">
</div>
{/block}

{block name="script"}
<script>
$(function(){
	getTree();
	layui.use(['form','laydate'], function(){
  		var form = layui.form,laydate = layui.laydate;
		laydate.render({
		    elem: '.test_time',
			type: 'datetime'
		});
		laydate.render({
		    elem: '.birthday',
			type: 'date'
		});
  	});

	$('.selectSchool').on('click',function(){
		selectSchoolBox = layer.open({
            type: 1,
            title: '请选择学校和专业',
            anim: 2,
            skin: 'layui-layer-molv', //加上边框
            area: ['300px', '450px'], //宽高
            content: $(".laycontent")
        });
	});

	$('#editForm').on('submit',function(){
		var params = $('#editForm').serialize();
		$.post('editSTInfo',params,function(res){
			if(res.code == 1){
				layer.alert(res.msg, {title: '友情提示', icon: 1, closeBtn: 0}, function(){
                    layer.closeAll();
					window.history.back();
                });
			}else{
				layer.msg(res.msg, {anim: 6});
			}
		});
		return false;
	});

	$(".showRemark").on('dblclick',function(){
		var remark = $(this).attr('data-param');
		$('.layRemark').html(remark);
		remarkBox = layer.open({
			type: 1,
            title: '备注信息',
            anim: 2,
            skin: 'layui-layer-molv', //加上边框
            area: ['300px', '450px'], //宽高
            content: $('.layRemark')
		});
	});

	if("{$stInfo.id_photo_url}" != ""){
		$("#ID_Photo").css({"background":"url({$stInfo.id_photo_url}) no-repeat","background-size":"190px 271px"});
	}
});
function getTree(){
    layui.use(['tree', 'layer'], function(){
        var layer = layui.layer;

        $.getJSON("{:url('product/school')}", function(res){
            if(111 == res.code){
                window.location.reload();
            }
            layui.tree({
                elem: '#tree'
                ,nodes: res.data
                ,click: function(node){
                    nowNode = node;
                    if(node.pid != 0){
                    	$('.major').val(node.name);
                    	$('.major_id').val(node.id);
                    	for(var i=0;i<res.data.length;i++){
                    		if(node.pid == res.data[i].id){
                    			$('.school').val(res.data[i].name);
                    			$('.school_id').val(res.data[i].id);
                    		}
                    	}
                    	layer.close(selectSchoolBox);
                    }
                }
            });
        });

        $.getJSON("{:url('product/classify')}", function(res){
            layui.tree({
                elem: '#classifytree'
                ,nodes: res.data
                ,click: function(node){
                    nowNode = node;
                	$('.selectClassify').val(node.name);
                	$('.c_id').val(node.id);
                	layer.close(selectclassifyBox);
                }
            });
        });

        $.getJSON("{:url('product/attr')}",function(res){
        	var attrhtml = '';
			for(var i=0;i<res.data.length;i++){
				attrhtml += '<div class="layui-form-item">';
				attrhtml += '<label class="layui-form-label attrName">'+ res.data[i].name +'</label>';
				attrhtml += '<div class="layui-input-inline"><select class="attrVal"><option value="">请选择</option>';
				for(var j=0;j<res.data[i].children.length;j++){
					attrhtml +='<option value="'+ res.data[i].id + '-' + res.data[i].children[j].id +'">'+ res.data[i].children[j].name +'</option>';
				}
				attrhtml += '</select></div></div>';
				$('#attrbox').html(attrhtml);
				var form = layui.form;
				form.render();
			}
        })
    });
}
</script>
{/block}
